# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=wgcf
pkgver=2.2.20
pkgrel=0
pkgdesc="Unofficial CLI for Cloudflare Warp"
url="https://github.com/ViRb3/wgcf"
arch="all"
license="MIT"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/ViRb3/wgcf/archive/refs/tags/v$pkgver.tar.gz"

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v

	for shell in bash fish zsh; do
		./wgcf completion $shell > wgcf.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 wgcf -t "$pkgdir"/usr/bin/

	install -Dm644 wgcf.bash \
		"$pkgdir"/usr/share/bash-completion/completions/wgcf
	install -Dm644 wgcf.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/wgcf.fish
	install -Dm644 wgcf.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_wgcf
}

sha512sums="
19d694f225e745d308551822b8e2a73c859dff74812e5e312fcd764cb796c5d0c77bab10dbbeb960d633ce76c96a66955390ec90c6408bd8160578d894dc658b  wgcf-2.2.20.tar.gz
"
